package book;

public class text {

    public static void main(String[] args) {
        try {
            char[] a = {1};
            System.out.println(a[2]);
            System.out.println(a.length);
        } catch (NullPointerException e) {
            System.out.println("空指针引用");
            //throw new NullPointerException("引用了空指针");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组越界");
            System.out.println(e.getSuppressed());
            e.addSuppressed(new ArrayIndexOutOfBoundsException());
            System.out.println(e.getSuppressed());
            System.out.println(e.getStackTrace());        } catch (Throwable e) {
            System.out.println("其他错误");
        } finally {
            System.out.println("结束");
        }
    }
}
